﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class WordSection
    {
        private readonly object _lock = new object();

        private WordHeadersFooters _headers;
        public WordHeadersFooters Headers
        {
            get
            {
                if (_headers == null)
                {
                    lock (_lock) { if (_headers == null) { _headers = new WordHeadersFooters(_section.Headers) { Section = this }; } }
                }
                return _headers;
            }
        }

        private WordHeadersFooters _footers;
        public WordHeadersFooters Footers
        {
            get
            {
                if (_footers == null)
                {
                    lock (_lock) { if (_footers == null) { _footers = new WordHeadersFooters(_section.Footers) { Section = this }; } }
                }
                return _footers;
            }
        }

        private Section _section;

        public WordDocument Document
        {
            get;
            internal set;
        }

        internal WordSection(Section section)
        {
            _section = section;
        }
    }
}
